<?php

namespace yiike\company\model;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yiike\company\model\TtycTokerComboOrder;

/**
* TtycTokerComboOrderSearch represents the model behind the search form about `yiike\company\model\TtycTokerComboOrder`.
*/
class TtycTokerComboOrderSearch extends TtycTokerComboOrder
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[[ 'uid', 'toker_id', 'combo_id', 'credit', 'day_limit', 'pid', 'ppid', 'community_id', 'company_id', 'is_pay', 'pay_at', 'status', 'created_at', 'updated_at'], 'integer'],
            [['trade_id',  'name', 'mobile', 'location_p', 'location_c', 'location_a', 'address', 'express_company', 'express_code'], 'safe'],
            [[ 'task_money', 'task_tyc', 'parent1_commision', 'parent2_commision', 'community_commision', 'company_commision'], 'number'],
];
}

/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}

/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = TtycTokerComboOrder::find();

$dataProvider = new ActiveDataProvider([
'query' => $query,
]);

$this->load($params);

if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}

$query->andFilterWhere([
            'id' => $this->id,
            'uid' => $this->uid,
            'toker_id' => $this->toker_id,
            'combo_id' => $this->combo_id,
            'price' => $this->price,
            'credit' => $this->credit,
            'task_money' => $this->task_money,
            'task_tyc' => $this->task_tyc,
            'day_limit' => $this->day_limit,
            'parent1_commision' => $this->parent1_commision,
            'parent2_commision' => $this->parent2_commision,
            'community_commision' => $this->community_commision,
            'company_commision' => $this->company_commision,
            'pid' => $this->pid,
            'ppid' => $this->ppid,
            'community_id' => $this->community_id,
            'company_id' => $this->company_id,
            'is_pay' => $this->is_pay,
            'pay_at' => $this->pay_at,
            'status' => $this->status,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'trade_id', $this->trade_id])
            ->andFilterWhere(['like', 'pay_id', $this->pay_id])
            ->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'sub_title', $this->sub_title])
            ->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'mobile', $this->mobile])
            ->andFilterWhere(['like', 'location_p', $this->location_p])
            ->andFilterWhere(['like', 'location_c', $this->location_c])
            ->andFilterWhere(['like', 'location_a', $this->location_a])
            ->andFilterWhere(['like', 'address', $this->address])
            ->andFilterWhere(['like', 'express_company', $this->express_company])
            ->andFilterWhere(['like', 'express_code', $this->express_code]);

return $dataProvider;
}
}